﻿CREATE TABLE [dbo].[PiPermission] (
    [Id]                   INT            IDENTITY (1, 1) NOT NULL,
    [ResourceCategory]     NVARCHAR (50)  NOT NULL,
    [ResourceId]           INT            NOT NULL,
    [PermissionId]         INT            NOT NULL,
    [PermissionConstraint] NVARCHAR (800) NULL,
    [Enabled]              INT            CONSTRAINT [DF__PiPermiss__Enabl__4CA06362] DEFAULT ((1)) NOT NULL,
    [DeleteMark]           INT            CONSTRAINT [DF__PiPermiss__Delet__4D94879B] DEFAULT ((0)) NOT NULL,
    [Description]          NVARCHAR (500) NULL,
    [CreateOn]             DATETIME       CONSTRAINT [DF__PiPermiss__Creat__4E88ABD4] DEFAULT (getdate()) NOT NULL,
    [CreateBy]             NVARCHAR (50)  NOT NULL,
    [CreateUserId]         NVARCHAR (50)  NOT NULL,
    [ModifiedOn]           DATETIME       NULL,
    [ModifiedBy]           NVARCHAR (50)  NULL,
    [ModifyUserId]         NVARCHAR (50)  NULL,
    CONSTRAINT [PK_PIPERMISSION] PRIMARY KEY NONCLUSTERED ([Id] ASC),
    CONSTRAINT [FK_Permission_PermissionId] FOREIGN KEY ([PermissionId]) REFERENCES [dbo].[PiPermissionItem] ([Id])
);

